package example.demo.juc;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

public class JucDemo {
    public static void main(String[] args) throws Exception {
//        ReentrantLock reentrantLock = new ReentrantLock();
//        new Thread(reentrantLock::lock).start();
//        TimeUnit.SECONDS.sleep(1);
//        reentrantLock.lock();
//        reentrantLock.unlock();
//        Thread.currentThread().interrupt();
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        Lock readLock = readWriteLock.readLock();
        Lock writeLock = readWriteLock.writeLock();
        readLock.lock();
        readLock.unlock();
        writeLock.lock();
        writeLock.unlock();
    }
}
